<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../../js/mui.min.js"></script>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../css/global.css">
		<link rel="stylesheet" type="text/css" href="../../css/app.css" />
		<script src="../../js/getURLParam.js"></script>
	</head>
	<body>
		<div class="mui-content" >
			<button id="changePass" type="button" class="mui-btn mui-btn-block mui-btn-primary">修改密码</button>
			<button id="unbindPhone"  type="button" onclick="jiechubang()"  class="mui-btn mui-btn-block mui-btn-primary" >解除手机绑定</button>
			<button id="logout" type="button" class="mui-btn mui-btn-block mui-btn-primary" >注销系统</button>
			<p>手势密码</p>
			<div class="mui-switch mui-active" id="switchDiv">
				<div class="mui-switch-handle"></div>
			</div>
			<!--<p>地图聚合</p>
			<div class="mui-switch mui-active" id="switchMapDiv">
				<div class="mui-switch-handle"></div>
			</div>-->
		</div>
	</body>
	<script src="../../js/mui.min.js"></script>
	<script>
		mui.init({
			 gestureConfig:{
				   tap: true, //默认为true
			  	}
		});
		var sessionid=GetQueryString("sessionid");
		var accountid=GetQueryString("accountId");
	    var proversion=GetQueryString("proVersion");
		(function($) {
		
		   //获取手势密码的状态
		   mui.ajax('../../../APP/handpwd', {
		   	//mui.ajax('../../../APP/handpwd', {
					data: {
						param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '"}'
					},
					dataType: 'jsonp', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						var jsonObj = window.JSON.parse(data);
						if (jsonObj.resultCode == "1") {
							//获取返回数据的data
							var resultdata = jsonObj.data;
							var s =document.getElementById("switchDiv");
							if (resultdata.pswdState=='1') {
								s.className="mui-switch mui-active";
							}else{
								s.className="mui-switch";
							}
						}
					}
				});
		})(mui);
			//获取地图聚合开关的状态
		 /*  mui.ajax(getrequestURL()+'APP/getmapPolystate', {
					data: {
						param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '"}'
					},
					dataType: 'jsonp', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						var jsonObj = window.JSON.parse(data);
						if (jsonObj.resultCode == "1") {
							//获取返回数据的data
							var resultdata = jsonObj.data;
							var maps =document.getElementById("switchMapDiv");
							if (resultdata.pswdState=='1') {
								maps.className="mui-switch mui-active";
							}else{
								maps.className="mui-switch";
							}
						}
					}
				});
		*/
	
		
		//跳转 修改密码 页面
		document.getElementById("changePass").addEventListener("tap",function(){
			window.webkit.messageHandlers.set_account.postMessage();
		});
	//注销系统
		document.getElementById("logout").addEventListener("tap",function(){
			window.webkit.messageHandlers.logout.postMessage();
		});
		
		//解除手机绑定
		function jiechubang() {
			var btnArray = ['否', '是'];
			mui.confirm('是否解除手机绑定，确认？', '警告！', btnArray, function(e) {
				if (e.index == 1) {
					
					mui.ajax('../../../APP/cleanBanging', {
					data: {
					param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '"}'
					},
						dataType:'jsonp',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:1000000,//超时时间设置为10秒；
						
						success: function(data) {
							var jsonObj = window.JSON.parse(data);
							var resultdata = jsonObj.data;
							if (jsonObj.resultCode == "1") {
								if(resultdata.state=="1"){
									mui.toast('解除绑定成功！');
								}else{
									mui.toast('解除绑定失败！');
								}
								
							} else {
								mui.toast('解除绑定失败！');
							}
						},
						error: function(xhr, type, errorThrown) {
							mui.toast('解除绑定失败！');
						}
					});
				} else {
					mui.toast('你取消了解除绑定');
				}
			})
		}
		
		//注销系统
		function loginout(){
			
			var btnArray = ['否', '是'];
			mui.confirm('是否注销系统，确认？', '警告！', btnArray, function(e) {
				if (e.index == 1) {
						mui.ajax('../../../APP/loginOut', {
						data: {
							param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '"}'
						},
						dataType: 'jsonp', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						success: function(data) {
							var jsonObj = window.JSON.parse(data);
							if (jsonObj.resultCode == "1") {
								mui.toast('注销成功！');
								mui.openWindow("../../index.html");
							} else {
								mui.toast('注销失败！');
							}
						},
						error: function(xhr, type, errorThrown) {
							mui.toast('注销失败！');
						}
					});
					
				} else {
					mui.toast('你已取消注销');
				}
			})
		
		}
		
		//手势密码
		switchDiv.addEventListener('toggle', function(event) {
			//event.detail.isActive 可直接获取当前状态
			if(event.detail.isActive){//打开手势密码开关
						var HandPassState=1;
						mui.ajax('../../../APP/sethandpwd', {
						//mui.ajax('../../../APP/sethandpwd', {
						data: {
							param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '","data":{"handpassstate":"'+HandPassState+'"}}'
						},
						dataType: 'jsonp', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						success: function(data) {
							var jsonObj = window.JSON.parse(data);
							if (jsonObj.resultCode == "1") {
								mui.toast('成功！');
								
							} else {
								mui.toast('修改失败！');
							}
						},
						error: function(xhr, type, errorThrown) {
						}
					});	
			}else{
						var HandPassState=0;
						mui.ajax('../../../APP/sethandpwd', {
						data: {
							param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '","data":{"handpassstate":"'+HandPassState+'"}}'
						},
						dataType: 'jsonp', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						success: function(data) {
							var jsonObj = window.JSON.parse(data);
							if (jsonObj.resultCode == "1") {
								mui.toast('成功！');
								
							} else {
								mui.toast('修改失败！');
							}
						},
						error: function(xhr, type, errorThrown) {
						}
					});	
			}
		});
		//地图聚合开关
		/*switchMapDiv.addEventListener('toggle', function(event) {
			//event.detail.isActive 可直接获取当前状态
			if(event.detail.isActive){//打开开关
						var dmapPolystate=1;
						mui.ajax('http://222.223.231.137:8008/IEMS_APP_IOSG/APP/AddmapPolystate', {
						data: {
							param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '","data":{"dmapPolystate":"'+dmapPolystate+'"}}'
						},
						dataType: 'jsonp', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						success: function(data) {
							var jsonObj = window.JSON.parse(data);
							if (jsonObj.resultCode == "1") {
								mui.toast('成功！');
								
							} else {
								mui.toast('修改失败！');
							}
						},
						error: function(xhr, type, errorThrown) {
						}
					});	
			}else{
						var dmapPolystate=0;
						mui.ajax('http://222.223.231.137:8008/IEMS_APP_IOSG/APP/AddmapPolystate', {
						data: {
							param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '","data":{"dmapPolystate":"'+dmapPolystate+'"}}'
						},
						dataType: 'jsonp', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						success: function(data) {
							var jsonObj = window.JSON.parse(data);
							if (jsonObj.resultCode == "1") {
								mui.toast('成功！');
								
							} else {
								mui.toast('修改失败！');
							}
						},
						error: function(xhr, type, errorThrown) {
						}
					});	
			}
			
		});*/
</script>
</html>